//
//  YSReviewsComtCell.m
//  Yueshi
//
//  Created by Northwan on 15/8/17.
//  Copyright (c) 2015年 悦食中国. All rights reserved.
//

#import "YSReviewsComtCell.h"
@interface YSReviewsComtCell()
@property (weak, nonatomic) IBOutlet UIImageView *headImgView;
@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
@property (weak, nonatomic) IBOutlet UILabel *timeLabel;
@property (weak, nonatomic) IBOutlet UILabel *contentLabel;

@end
@implementation YSReviewsComtCell

+(instancetype)initWithTableView:(UITableView *)tableView{
    static NSString *CellIdentiferId = @"YSReviewsComtCell";
    YSReviewsComtCell *cell =  [tableView dequeueReusableCellWithIdentifier:CellIdentiferId];
    if(cell == nil){
        NSArray *nibs = [[NSBundle mainBundle]loadNibNamed:CellIdentiferId owner:nil options:nil];
        cell = [nibs lastObject];
    }
    return cell;
}

-(void)setCommentInfo:(YSCommentInfo *)commentInfo{
    [self.headImgView setImageURLStr:commentInfo.headImage];
    [self.nameLabel setText:commentInfo.commentName];
    [self.timeLabel setText:commentInfo.commentTime];
    
    if(commentInfo.replyName){
        NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString: [NSString stringWithFormat: @"@%@ %@",commentInfo.replyName, commentInfo.commentContent]];
        [str addAttribute:NSForegroundColorAttributeName value:ThemeColor range:NSMakeRange(0,commentInfo.replyName.length +1)];
    
        self.contentLabel.attributedText = str;
    }else{
        [self.contentLabel setText:commentInfo.commentContent];
    }

}

@end
